package com.hrvsr.scheduler.standardalone;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import com.hrvsr.common.Request;
import com.hrvsr.scheduler.DuplicateRemover;
import com.hrvsr.scheduler.Scheduler;

public class StandardAloneScheduler implements Scheduler {
	private BlockingQueue<Request> queue = new LinkedBlockingQueue<Request>();
	private DuplicateRemover duplicateRemover = new HashSetDuplicateRemover();
	
	@Override
	public Request poll() {
		return queue.poll();
	}

	@Override
	public void offer(Request request) {
		if(!duplicateRemover.contains(request)){
			queue.offer(request);
			duplicateRemover.add(request);
		}
	}

	@Override
	public void putEvenDuplicate(Request request) {
		queue.offer(request);
	}


	@Override
	public long size() {
		return queue.size();
	}
	
}
